<template>
  <!--内容...-->
  <div>
    <div class="mescroll">
      <mescroll-vue ref="mescroll" :up="mescrollUp" @init="mescrollInit">
        <div v-for="item in cardTrackingData">
          <div :class="{ active: !brandFold }" class="card">
            <div class="content">
              <div class="contentUp">
                <div
                  class="name"
                  v-if="item.hasOwnProperty('isTrackingInfoData')"
                >
                  <ul>
                    <li><span>跟进时间：</span>{{ item.trackingDate }}</li>
                    <li><span>联系人：</span>{{ item.trackingContact }}</li>
                    <li><span>沟通形式：</span>{{ item.communicationType }}</li>
                    <li><span>客户类型：</span>{{ item.customerType }}</li>
                    <li><span>客户进展：</span>{{ item.customerProgress }}</li>
                    <li>
                      <span>沟通内容：</span>{{ item.communicationContent }}
                    </li>
                    <li><span>跟进人：</span>{{ item.creater }}</li>
                    <li>
                      <span>下次跟进时间：</span>{{ item.nextTrackingDate }}
                    </li>
                  </ul>
                </div>
                <div
                  class="name"
                  v-if="item.hasOwnProperty('isRecordInfoData')"
                >
                  <ul>
                    <li>
                      <span>拜访/宴请/参会时间：</span
                      >{{ item.trackingDateStart }}
                    </li>
                    <li><span>报备类别：</span>{{ item.recordType }}</li>
                    <li><span>跟踪情况：</span>{{ item.recordContent }}</li>
                    <li><span>下次跟进计划：</span>{{ item.nextPlan }}</li>
                    <li>
                      <span>项目主要障碍：</span>{{ item.majorDifficulty }}
                    </li>
                    <li><span>需要的支持：</span>{{ item.neededSupport }}</li>
                    <li><span>竞争对手：</span>{{ item.competitor }}</li>
                    <li>
                      <span>预计成交时间：</span>{{ item.expectedClosingDate }}
                    </li>
                    <li>
                      <span>计划招生人数：</span>{{ item.plannedPeopleNum }}
                    </li>
                  </ul>
                </div>
              </div>
              <div class="contentDown">
                <div class="contentDownList"></div>
              </div>
            </div>
          </div>
        </div>
      </mescroll-vue>
    </div>
  </div>
</template>

<script>
import Cookies from "js-cookie";
import axios from "axios";
import MescrollVue from "../../../../static/mescroll/mescroll.vue";
import "../../../../static/mescroll/mescroll.min";
export default {
  name: "CardTracking",
  components: {
    MescrollVue
  },
  props: {
    cardList: {},
    cardTrackingData: [],
    tileBgc: {
      type: String
    },
    titleLabel: {
      type: String
    }
  },
  data() {
    return {
      instance: "",
      isRouterAlive: true,
      brandFold: true,
      mescroll: null,
      mescrollDown: {},
      mescrollUp: {
        // 上拉加载的配置.
        callback: this.upCallback
      },
      page: {
        pageNum: 1,
        pageSize: 10
      },
      dataList: [],// 列表数据
      newLIst:[]
    };
  },
  methods: {
    // 展开收起
    changeFoldState() {
      this.brandFold = !this.brandFold;
    },
    // mescroll组件初始化的回调,可获取到mescroll对象
    mescrollInit(mescroll) {
      this.mescroll = mescroll; // 如果this.mescroll对象没有使用到,则mescrollInit可以不用配置
    },
    getNewDataList(){
      console.log(this.newLIst)
    },
    
    upCallback(page, mescroll) {
      //判断是哪个页面加载哪个页面的接口数据
      let queryPageName = this.$route.query.name;
      if (
        queryPageName == "mychinaedu" ||
        queryPageName == "addMychinaeduTracking"
      ) {
        let params = {
          pageNum: page.num, // 页码
          pageSize: page.size, // 每页长度
          customerId: this.$route.query.id
        };
        this.$api.agent
          .investmentTrackingInfoChinaedu(params)
          .then(response => {
            // 请求的列表数据
            let  arr = response.investmentTrackingVos;
            // 如果是第一页需手动置空列表
            if (page.pageNum === 1) this.dataList = [];
            // 把请求到的数据添加到列表
            this.dataList = this.dataList.concat(arr);
            // 数据渲染成功后,隐藏下拉刷新的状态
            this.$nextTick(() => {
              mescroll.endSuccess(arr.length);
            });
          })
          .catch(e => {
            // 联网失败的回调,隐藏下拉刷新和上拉加载的状态;
            mescroll.endErr();
          });
      }
      查询报备记录
      if (queryPageName == "myschool") {
        let params = {
          pageNum: page.num, // 页码
          pageSize: page.size, // 每页长度
          id: this.$route.query.id
        };
        this.$api.school
          .detailRecordInfo(params)
          .then(response => {
            // 请求的列表数据
            let arr = response.trackLists;
            // 如果是第一页需手动置空列表
            if (page.pageNum === 1) this.dataList = [];
            // 把请求到的数据添加到列表
            this.dataList = this.dataList.concat(arr);
            // 数据渲染成功后,隐藏下拉刷新的状态
            this.$nextTick(() => {
              mescroll.endSuccess(arr.length);
            });
          })
          .catch(e => {
            // 联网失败的回调,隐藏下拉刷新和上拉加载的状态;
            mescroll.endErr();
          });
      }
    },
    cardListTo(val) {
      this.$router.push({
        path: "/Mobile/CustomerInfo/CustomerInfo",
        query: {
          id: val.id,
          name: "mychinaedu"
        }
      });
    }
  },
  mounted() {
    // console.log(this.cardTrackingData)
  },
  beforeDestroy(){
    this.mescroll.destroy();
  }
};
</script>

<style scoped lang="scss">
.mescroll {
  height: 400px;
}
.card {
  position: relative;
  .content {
    font-size: 0.34rem;
    .title {
      width: 2.86rem;
      height: 0.81rem;
      line-height: 0.81rem;
      color: #fff;
      font-weight: bold;
      font-size: 0.43rem;
      border-radius: 0px 100px 100px 0px;
    }
    .contentUp {
      display: flex;
      flex-direction: row;
      margin-top: 0.48rem;
      justify-content: space-between;
      .name {
        margin-left: 0.49rem;
        font-size: 0.4rem;
        font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
        font-weight: bold;
        color: rgba(51, 51, 51, 1);
        line-height: 47px;
        ul {
          padding-left: 0;
          li {
            span {
              color: #cccccc;
            }
            color: #333333;
            font-size: 0.38rem;
            list-style: none;
            height: 0.49rem;
            line-height: 0.49rem;
            margin-top: 0.26rem;
            text-align: left;
          }
        }
      }
    }

    .contentDown {
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      margin-left: 0.4rem;
      .contentDownList {
        display: block;
        margin-bottom: 0.26rem;
        text-align: left;
      }
    }
    .info {
      text-align: center;
      position: absolute;
      top: 83%;
      bottom: 0;
      left: 0;
      right: 0;
      font-size: 0.32rem;
      padding-top: 0.5rem;
      border-top: 1px solid #f0f0f0;
      padding-bottom: 0.47rem;
      background: #fff;
    }
  }
  margin: 0 auto;
  width: 9.2rem; //670px 计算公式 设计稿的px/75
  height: 8.1rem;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0px 3px 8px 0px rgba(204, 204, 204, 0.5);
  margin-bottom: 0.32rem;
  overflow: hidden;
}
.active {
  height: auto;
  overflow: scroll;
  .content {
    .info {
      top: 90%;
    }
  }
}
</style>
